﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Interview.Service
{
    public class WarningService
    {
        private static readonly WarningService instance = new WarningService();
        private List<IWarningService> warningServices = new List<IWarningService>();

        private WarningService()
        {
            // 默认添加控制台报警器
            warningServices.Add(new WarningServiceSingle());
        }

        public static WarningService Instance => instance;

        public void RegisterAlarm(IWarningService alarm)
        {
            warningServices.Add(alarm);
        }

        public void Alert(string message)
        {
            foreach (var alarm in warningServices)
            {
                alarm.Alert(message);
            }
        }
    }
}
